<template>
	<view class="commodity">
	<!-- 	<uni-nav-bar title="岗位管理" left-icon="left" @clickLeft="navBack" backgroundColor="#2CB9A4" color="#F8F8F8"></uni-nav-bar> -->
		<view class="add">
			<u-button class="custom-style" text="新增岗位"
				customStyle="background: #2CB9A4;color:#fff;margin-top:20px;border-radius: 20rpx;width:30%;margin-left:0;padding:0 30rpx;height: 30px;"
				@click="addCommodity">
			</u-button>
		</view>
		<view class="list f-column" v-for="(item,index) in list" :key="index">
			<view class="list_item" >
				<view class="content">
					<view class="item">
						<view class="entityList">
							<view class="topName" style="font-size: 32rpx;">
								<view class="right" style="color: #2CB9A4;">
									岗位名称：{{item.name}}
								</view>
							</view>
							<view class="name">
								<text class="text">职责：{{item.scope}}</text>
							</view>
						</view>
					</view>
					<view class="commodiyBot">
						<view class="botBtn">
							<u-button class="custom-style" text="删除"
								customStyle="background: #FF6666;color:#fff;margin-top:10px;border-radius: 20rpx;"
								@click="goDelete(item.id)">
							</u-button>
						</view>
						<view class="botBtn">
							<u-button class="custom-style" text="编辑"
								customStyle="background: #00D5CE;color:#fff;margin-top:10px;border-radius: 20rpx;"
								@click="goEdit(item)">
							</u-button>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="noMore" v-if="last_page==form.page&&list.length!=0"
			style="text-align: center;color: #797575;margin-top: 20rpx;padding-bottom: 60rpx;">
			数据加载完成...
		</view>
		<u-empty text="暂无列表哦~~" mode="list" v-if="list.length==0" margin-top='50'></u-empty>
		<u-modal :show="showDelete" :closeOnClickOverlay="true" :showCancelButton='true' :title="'提示'"
			@confirm='confirm' @cancel='showDelete=false' :content="'是否删除该岗位？'" confirmColor="#2CB9A4"></u-modal>
	</view>
</template>

<script>
	import {
		listPost,delPost
	} from '@/request/api.js'
	export default {
		data() {
			return {
				value1: true,
				showDelete:false,
				list: [
				],
				last_page: 1,
				form: {
					page: 1,
				},
			};
		},
		onShow() {
			this.form.page = 1
			this.list = []
			this.getList()
		},
		onReachBottom() {
			// console.log(111)
			if (this.form.page < this.last_page) {
				this.form.page = this.form.page + 1
				this.getList()
			}
		},
		methods:{
			async confirm() {
				let res = await delPost({
					id: this.deleteId
				})
				this.showDelete = false;
				uni.showToast({
					icon: 'none',
					title: '删除成功！'
				})
				this.form.page = 1
				this.list = []
				this.getList()
			},
			goEdit(item) {
				uni.navigateTo({
					url: '/pages/positionManagement/addPosition?data=' + JSON.stringify(item)
				})
			},
			goDelete(e) {
				console.log(e, 'eeee')
				this.deleteId = e;
				this.showDelete = true;
			},
			async getList() {
				let res = await listPost(this.form)
				this.list = this.list.concat(res.data.data)
				this.last_page = res.data.last_page
				console.log(res, '商品列表')
			},
			addCommodity(){
				uni.navigateTo({
					url:'/pages/positionManagement/addPosition'
				})
			}
		}
	}
</script>

<style lang="scss">
	.commodity {
		font-size: 30rpx;
		padding: 20rpx;
		.add{
			    display: flex;
			    justify-content: space-between;
		}
		.list {
			margin-top: 20rpx;

			.content {
				background-color: #fff;
				box-shadow: 0px 0px 10px rgba(8, 23, 56, 0.05);
				border-radius: 10px;
				padding: 20rpx;
				.conBot {
					align-items: flex-end;

					.f-row {
						display: flex;
						align-items: flex-end;
					}

					.goNear {
						background: #2CB9A4;
						color: #fff;
						height: 60rpx;
						justify-content: center;
						align-items: center;
						border-radius: 10rpx;
						padding: 10rpx 20rpx;
						font-size: 32rpx;
						align-items: center;
					}

					display: flex;
					justify-content: space-between;
					color: #2CB9A4;

					.down {
						background: #C0EAE4;
						justify-content: center;
						display: flex;
						flex-direction: column;
						align-items: center;
						padding: 10rpx;
						font-size: 22rpx;
						border-radius: 10rpx;
						margin-right: 10rpx;
					}

					.down_price {
						margin-right: 10rpx;
					}

					.price {
						margin-right: 10rpx;
					}
				}
			}

			.list_item {
				display: flex;
				flex-direction: column;
				// background: #2CB9A4;
				border-radius: 20rpx;
				// padding: 20rpx;

				.title {
					color: #fff;
					font-size: 30rpx;
					font-weight: 600;
				}

				.item {
					display: flex;
					color: #505050;
					margin: 15rpx 0;
					border-bottom: 0.5px solid rgba(217, 217, 217, 0.3);
					padding-bottom: 15rpx;
					box-sizing: border-box;
					background: #fff;
					border-radius: 20rpx;

					.icon {
						width: 72rpx;
						height: 72rpx;
						width: 100rpx;
						height: 100rpx;

						.image {
							width: 100%;
							height: 100%;
						}
					}

					.entityList {
						flex: 1;
						display: flex;
						flex-direction: column;
						overflow: hidden;
						text-overflow: ellipsis;
						justify-content: space-between;

						.name {
							display: flex;
							justify-content: space-between;
							margin-left: 15rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							color: #BABABA;
							font-size: 26rpx;

							.text {
								margin-top:15rpx;
								overflow: hidden;
								text-overflow: ellipsis;
								white-space: nowrap;
							}

							.image {
								width: 26rpx;
								height: 26rpx;
								margin-right: 10rpx;
							}
						}

						.topName {
							display: flex;
							justify-content: space-between;
							margin-left: 15rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							color: #000;
							font-weight: 600;
							font-size: 26rpx;

							.text {
								width: 60%;
								overflow: hidden;
								text-overflow: ellipsis;
								white-space: nowrap;
							}

							.image {
								width: 26rpx;
								height: 26rpx;
								margin-right: 10rpx;
							}
						}
					}
				}

				.commodiyBot {
					display: flex;
					flex-direction: row-reverse;
					.botBtn{
						margin-left: 30rpx;
					}
				}
			}
		}
	}
</style>